<?php

namespace app\util;

use Firebase\JWT\JWT as J;

class JWT
{
    // 生成token
    public static function createToken($data = [], $key = 'key', $expired = 7200)
    {
        $time = time();
        $token = [
            'iat' => $time,
            'nbf' => $time,
            'exp' => $time + $expired,
            'data' => $data
        ];

        return J::encode($token, $key);
    }
}